jQ(function(){
	jQ("div.my_clips_menu a.addclip").addClass("addcliponit");
	window.onbeforeunload = leavenotice;
	jQ("#clipevent-eventid").val(0);
	jQ("#clip_title_input").val("");
	jQ("#clip_address_input").val("");
	jQ("#clip_enddate_input").val("");
	jQ("#addclip_maincontent").data("cliptype",4);
	
//	jQ("#addclip_maincontent").data("moredetail",0);
//	jQ("#addclip_maincontent").data("isinvite",0);
//	jQ("#addclip_maincontent").data("share2",1);
	jQ("#clippic_hitime").val(new Date().getTime());
	jQ("#clippic_hitime2").val(new Date().getTime());
	jQ("#clipevent-picid").val("0");
	jQ(".sharepart").hide();
	jQ("#clip_isoneday_cbx").data("checked",0);
	jQ("#addclip_memotitle").hide();
//	jQ("input.hminput").val(0);
	
	checkIshasAsync();
	var usertype=eval(jQ("#var_usertype").val());
	if(usertype==2){
		initDatepicker(true);
		initCCInterface();
		jQ("#clipmanagehead li[queryby='own']").click(function(){
			window.location.href=jQ("#ctxVal").val()+"/myclip/clip_list.html";
		});
		jQ("#clipmanagehead li[queryby='own']").siblings().remove();
		var tempboxhtml="<li queryby=\"cache\" clickonclz=\"cacheon\" enabled=\"1\" class=\"\">草稿箱</li>";
		jQ("#clipmanagehead li:first").after(tempboxhtml);
		jQ("#clipmanagehead li[queryby='cache']").click(function(){
			window.location.href=jQ("#ctxVal").val()+"/myclip/clip_cache.html";
		});
		analyzeUrl();
	}else{
		initDatepicker(false);
		jQ("#clipmanagehead li").click(function(){
			var qb=jQ(this).attr("queryby");
			if(qb=="cache"||qb=="recycle"){
				window.location.href=jQ("#ctxVal").val()+"/myclip/clip_"+qb+".html";
			}else{
				window.location.href=jQ("#ctxVal").val()+"/myclip/clip_list.html#"+qb;
			}
		});
	}
	jQ("#clipmanagehead li").each(function(){
		if(jQ(this).hasClass("nonequery"))return;
		var clz=jQ(this).attr("clickonclz");
		jQ(this).mouseover(function(){
			jQ(this).addClass(clz);
		});
		jQ(this).mouseout(function(){
			jQ(this).removeClass(clz);
		});
	});
	initClipdefaultcontent();
	if(usertype==1){
		initContacts();
		jQ(".sharepart").show();
	}
	jQ("#findclipusers_div").hide();
	if(usertype==1){
		

		jQ("#cliptypetd b.clipradiobtn").click(function(){
			if(jQ(this).hasClass("clipradiobtnon")){
				return;
			}else{
				jQ("#cliptypetd span.typeon").removeClass("typeon");
				jQ(this).next().addClass("typeon");
				var onobj=jQ("#cliptypetd b.clipradiobtnon");
				onobj.removeClass("clipradiobtnon");
				jQ(this).addClass("clipradiobtnon");
				var typeval=eval(jQ(this).attr("typeval"));
				jQ("#addclip_maincontent").data("cliptype",typeval);
				if(typeval==2){
					jQ("#addclip_asyncweibo").data("asyncsina",0);
					jQ("div.snsasync").hide();
					jQ("div.laststepdiv div.optitem").css({ "margin-left": "-128px"});
					initDatepicker(false);
					jQ("#cliptype1moredetail").hide();
					jQ("#clip_isoneday_cbx").hide();
					jQ("#clip_isoneday_title").hide();
					jQ(".sharepart").hide();
					jQ("#clipcontent_checkboxes").hide();
					if(!jQ("#addclipbutton").hasClass("saveclip")){
						jQ("#addclipbutton").addClass("saveclip");
					}
					if(!jQ("#addclip_titlename").hasClass("person_plan"))
						jQ("#addclip_titlename").addClass("person_plan");
					jQ("#addclip_memotitle").show();
				}else if(typeval==1){
					jQ("#addclip_asyncweibo").data("asyncsina",0);
					jQ("div.snsasync").hide();
					jQ("div.laststepdiv div.optitem").css({ "margin-left": "-128px"});
					if(jQ("#clip_begindate_input").val()!=null&&jQ("#clip_begindate_input").val().length>0){
						jQ("#clip_begindate_input").next().text("00:00");
					}
					if(jQ("#clip_enddate_input").val()!=null&&jQ("#clip_enddate_input").val().length>0){
						jQ("#clip_enddate_input").next().text("00:00");
					}
					initDatepicker(true);
					jQ("#cliptype1moredetail").show();
					jQ("#clip_isoneday_cbx").show();
					jQ("#clip_isoneday_title").show();
					jQ(".sharepart").hide();
					jQ("#clipcontent_checkboxes").hide();
					if(!jQ("#addclipbutton").hasClass("saveclip")){
						jQ("#addclipbutton").addClass("saveclip");
					}
					if(!jQ("#addclip_titlename").hasClass("person_plan"))
						jQ("#addclip_titlename").addClass("person_plan");
					jQ("#addclip_memotitle").show();
				}else if(typeval==3){
					jQ("div.snsasync").show();
					jQ("div.laststepdiv div.optitem").css({ "margin-left": "25px"});
					if(jQ("#addclip_asyncweibo").hasClass("clipcheckboxon")){
						jQ("#addclip_asyncweibo").data("asyncsina",1);
					}else{
						jQ("#addclip_asyncweibo").data("asyncsina",0);
					}
					initDatepicker(false);
					jQ("#cliptype1moredetail").show();
					jQ("#clip_isoneday_cbx").show();
					jQ("#clip_isoneday_title").show();
					jQ(".sharepart").show();
					jQ("#clipcontent_checkboxes").show();
					jQ("#addclip_titlename").removeClass("person_plan");
					jQ("#addclip_memotitle").hide();
					var typeval=eval(jQ("#thirdstepchoose b.clipradiobtnon").attr("typeval"));
					jQ("#addclip_maincontent").data("cliptype",typeval);
					if(jQ("#addclipbutton").hasClass("saveclip")){
						jQ("#addclipbutton").removeClass("saveclip");
					}
					if(typeval==4){
						jQ("#findclipusers_div").hide();
						jQ("#requestclip_div").show();
					}else if(typeval==3){
						jQ("#requestclip_div").hide();
						jQ("#findclipusers_div").show();
					}
				}
			}
		});
		jQ("#thirdstepchoose b.clipradiobtn").click(function(){
			if(jQ(this).hasClass("clipradiobtnon")){
				return;
			}else{
				jQ("#thirdstepchoose span.clipchooseon").removeClass("clipchooseon");
				jQ(this).next().addClass("clipchooseon");
				var onobj=jQ("#thirdstepchoose b.clipradiobtnon");
				onobj.removeClass("clipradiobtnon");
				jQ(this).addClass("clipradiobtnon");
				var typeval=eval(jQ(this).attr("typeval"));
				jQ("#addclip_maincontent").data("cliptype",typeval);
				if(typeval==4){
					jQ("#findclipusers_div").hide();
					jQ("#requestclip_div").show();
				}else if(typeval==3){
					jQ("#requestclip_div").hide();
					jQ("#findclipusers_div").show();
				}
			}
		});
		jQ("#addclipcontactmbtab span").click(function(){
			if(jQ(this).hasClass("onit"))
				return;
			else{
				var conid=jQ("#addclipcontactmbtab span.onit").attr("conid");
				jQ("#"+conid).hide();
				jQ("#addclipcontactmbtab span.onit").removeClass().addClass("nor");
				var conshowid=jQ(this).attr("conid");
				jQ("#"+conshowid).show();
				jQ(this).removeClass().addClass("onit");
			}
		});
	}
	jQ("#viewopt").dialog({
		modal: true,
		bgiframe: true,
		autoOpen: false,
		closeOnEscape:false,
		draggable:false,
		height:200,
		buttons: {
			
			"确定": function() {
				var opt=jQ("#viewopt");
				var triggerfun=opt.data("function");
				opt.trigger(triggerfun);
				opt.removeData("function");
				jQ(this).dialog('close');
			},
			"取消": function() {
				var viewopt=jQ("#viewopt");
				var triggerfun=jQ("#viewopt").data("function");
				viewopt.unbind(triggerfun);
				viewopt.find("input.eventid").val("");
				viewopt.removeData("function");
				jQ(this).dialog('close');
			}
		},
		close: function() {
			jQ("#viewopt_p").show();
			jQ("#viewopt_img").hide();
		},
		open:function(){
		}
	});
	
	
	jQ("span.share-title input[name=shareraido]").click(function(){
		var val=eval(jQ(this).val());
		if(val==1){
			jQ("#share-contactchoose").fadeIn();
		}else{
			jQ("#share-contactchoose").fadeOut();
		}
	});
	
	jQ("input.searchdefault").val("输入您要搜索的档期内容");
	jQ("#deadlinedate_input").val("");
	if(jQ("#clip_begindate_input").val()=='0')
		jQ("#clip_begindate_input").val("");
	jQ("#addclipbutton").unbind("click").bind("click",addclip);
	jQ("#add_return_vcode_ipt").bind("focus",function(){
		if(!jQ(this).hasClass("onfocus")){
			jQ(this).val("");
			jQ(this).addClass("onfocus");
		}
	});
	jQ("#add_return_vcode_ipt").bind("blur",function(){
		if(jQ.trim(jQ(this).val()).length==0){
			jQ(this).val("4位数字");
			jQ(this).removeClass("onfocus");
		}
	});
});

function checkIshasAsync(){
	jQ.ajax({
		type:"POST",
		url: "userAjax!checkIshasAsync.action",
		async:false,
		data:{
			suffixurl:window.location.href
		},
		success:function(data){
			if(data.result==1){//说明存在
				jQ("#addclip_asyncweibo").data("asyncsina",1);
				jQ("#addclip_asyncweibo").data("isdisabled",0);
				jQ("#addclip_asyncweibo").unbind("click").bind("click",clickAsynccheckbox);
				jQ("#addclip_asyncweibo").parent().next("div.info").hide();
			}else if(data.result==-1){
				jQ("#accesstoken_inf").dialog({
					modal: true,
					bgiframe: true,
					autoOpen: false,
					closeOnEscape:false,
					draggable:false,
					height:200,
					buttons: {
						
						"重新授权": function() {
							window.onbeforeunload = null;
							var usertype=eval(jQ("#var_usertype").val());
							if(usertype==2){
								window.location.href=jQ("#ctxVal").val()+"/control/ccinfo.html?rebind=1";
							}else{
								window.location.href=jQ("#ctxVal").val()+"/control/userinfo.html?rebind=1";
							}
							jQ(this).dialog('close');
						},
						"解除绑定": function() {
							jQ.ajax({
								type: "POST",
								url: "userAjax!unbindUserSina.action",
								success:function(data){
									if(data.result){
										jQ("#addclip_asyncweibo").data("asyncsina",0);
										jQ("#addclip_asyncweibo").data("isdisabled",1);
										jQ("#addclip_asyncweibo").unbind("click");
										jQ("#addclip_asyncweibo").parent().next("div.info").show();
										var usertype=eval(jQ("#var_usertype").val());
										if(usertype==2){
											jQ("#addclip_asyncweibo").parent().next("div.info").find("a.gotobind").bind("click",function(){
												window.location.href=jQ("#ctxVal").val()+"/control/ccinfo.html";
											});
										}else{
											jQ("#addclip_asyncweibo").parent().next("div.info").find("a.gotobind").bind("click",function(){
												window.location.href=jQ("#ctxVal").val()+"/control/userinfo.html";
											});
										}
										jQ("#addclip_asyncweibo").addClass("disabledcheck");
									}else{
										clip_tips(data.errormsg);
									}
								}
							});
							
							jQ(this).dialog('close');
						}
					},
					close: function() {
						jQ("#addclip_asyncweibo").data("asyncsina",0);
						jQ("#addclip_asyncweibo").data("isdisabled",1);
						jQ("#addclip_asyncweibo").unbind("click");
						jQ("#addclip_asyncweibo").parent().next("div.info").show();
						var usertype=eval(jQ("#var_usertype").val());
						if(usertype==2){
							jQ("#addclip_asyncweibo").parent().next("div.info").find("a.gotobind").bind("click",function(){
								window.location.href=jQ("#ctxVal").val()+"/control/ccinfo.html";
							});
						}else{
							jQ("#addclip_asyncweibo").parent().next("div.info").find("a.gotobind").bind("click",function(){
								window.location.href=jQ("#ctxVal").val()+"/control/userinfo.html";
							});
						}
						jQ("#addclip_asyncweibo").addClass("disabledcheck");
					},
					open:function(){
					}
				});
				jQ("#accesstoken_inf p").empty().append("对不起，您绑定的新浪微博账户，授权即将过期，请重新授权。")
				jQ("#accesstoken_inf").parent().css('font', "14px \"Trebuchet MS\", sans-serif");
				jQ("#accesstoken_inf").dialog("open");
				
			}else{
				jQ("#addclip_asyncweibo").data("asyncsina",0);
				jQ("#addclip_asyncweibo").data("isdisabled",1);
				jQ("#addclip_asyncweibo").unbind("click");
				jQ("#addclip_asyncweibo").parent().next("div.info").show();
				var usertype=eval(jQ("#var_usertype").val());
				if(usertype==2){
					jQ("#addclip_asyncweibo").parent().next("div.info").find("a.gotobind").bind("click",function(){
						window.location.href=jQ("#ctxVal").val()+"/control/ccinfo.html";
					});
				}else{
					jQ("#addclip_asyncweibo").parent().next("div.info").find("a.gotobind").bind("click",function(){
						window.location.href=jQ("#ctxVal").val()+"/control/userinfo.html";
					});
				}
				jQ("#addclip_asyncweibo").addClass("disabledcheck");
			}
		}
	});
}

function clickAsynccheckbox(){
	if(jQ("#addclip_asyncweibo").hasClass("clipcheckboxon")){
		jQ("#addclip_asyncweibo").removeClass("clipcheckboxon");
		jQ("#addclip_asyncweibo").data("asyncsina",0);
	}else{
		jQ("#addclip_asyncweibo").addClass("clipcheckboxon");
		jQ("#addclip_asyncweibo").data("asyncsina",1);
	}
}

function initCCInterface(){
	jQ("#clipmanagehead li:first").nextAll().hide();
	jQ("#cliptypetd").hide();
	jQ("#firststep_pic").css("top","96px");
	jQ(".sharepart").hide();
	jQ("#usertype2share").show();
	jQ("#clipcontent_checkboxes").hide();
	if(!jQ("#addclip_titlename").hasClass("person_plan")){
		jQ("#addclip_titlename").addClass("person_plan");
	}
	jQ("#addclip_memotitle").show();
	jQ("#cliptype1moredetail").hide();
	jQ("#cliptypeccmore").show();
	initAddressSelection();
	jQ("#deadlinedate_input").val("");
	jQ("#deadlinedate_input").datepicker({
		yearRange : '1950:2020',
		dateFormat:'yy-mm-dd',
		changeMonth:true,
		changeYear:true,
		detailtime:true,
		beforeShow: function(i,e){  
			var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
			e.dpDiv.css('z-index', z);
			e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
		},
        onClose: function(dateText,inst) {
            var iobj=jQ("#deadlinedate_input").next();
        	var hourval=eval(jQ(inst.dpDiv).find("div.detailtime").find("input.cliptimehour").val());
        	if(hourval<10)
        		hourval="0"+hourval;
        	else if(hourval>23)
        		hourval="00";
        	var minval=eval(jQ(inst.dpDiv).find("div.detailtime").find("input.cliptimemin").val());
        	if(minval<10)
        		minval="0"+minval;
        	else if(minval>59)
        		minval="00";
        	iobj.val(hourval+":"+minval);
        	
        }
    });
	jQ("#ccmorecontent_btn a").click(function(){
		if(jQ(this).hasClass("on")){
			return;
		}else{
			var zone=jQ(this).attr("affect");
			jQ(this).addClass("on");
			jQ("#ccmorecontent_btn").nextAll("div."+zone).show();
		}
	});
	jQ("#usertype2share div.choose b.clipradiobtn").click(function(){
		if(jQ(this).hasClass("clipradiobtnon")){
			return;
		}else{
			var onobj=jQ("#usertype2share div.choose b.clipradiobtnon");
			onobj.removeClass("clipradiobtnon");
			jQ(this).addClass("clipradiobtnon");
			//加入保存选择的数据库
			var typeval=eval(jQ(this).attr("typeval"));

			if(typeval==1){//分组用户
				jQ("div.snsasync").hide();
				jQ("div.laststepdiv div.optitem").css({ "margin-left": "-128px"});
				
				jQ("#addclip_asyncweibo").data("asyncsina",0);				
				jQ(this).nextAll("a.shareusericon").show();
				jQ(this).nextAll("a.shareusericon").unbind("click").bind("click",showContactDetailTip);
				jQ("#iscanfwbox").show();
				
				jQ("#iscanfwbox span.clipcheckbox").unbind("click").bind("click",function(){
					jQ(this).toggleClass("clipcheckboxon");
					
				});
			}else if(typeval==0){
				jQ("div.snsasync").show();
				jQ("div.laststepdiv div.optitem").css({ "margin-left": "25px"});
				if(jQ("#addclip_asyncweibo").hasClass("clipcheckboxon")){
					jQ("#addclip_asyncweibo").data("asyncsina",1);
				}else{
					jQ("#addclip_asyncweibo").data("asyncsina",0);
				}
				jQ(this).nextAll("a.shareusericon").hide();
				jQ("#iscanfwbox span.clipcheckbox").unbind("click");
			}
		}
	});
	jQ("#addclipcontactmbtab span").click(function(){
		if(jQ(this).hasClass("onit"))
			return;
		else{
			var conid=jQ("#addclipcontactmbtab span.onit").attr("conid");
			jQ("#"+conid).hide();
			jQ("#addclipcontactmbtab span.onit").removeClass().addClass("nor");
			var conshowid=jQ(this).attr("conid");
			jQ("#"+conshowid).show();
			jQ(this).removeClass().addClass("onit");
		}
	});
	//加判断关于显示草稿
	jQ("#addtempclipbtn").show();
	jQ("#addtempclipbtn").click(saveTemp);
//	saveTemp
	initSubscribersContacts();
}

function initSubscribersContacts(){
	jQ("#addclipcontactmbtab span").eq(0).text("订阅用户");
	jQ("#addclipcontactmbtab span").eq(1).text("分组");
	jQ.ajax({
		type:"POST",
		url: "contactAjax!loadSubscriberAll.action",
		async:false,
		success:function(data){
			var contactcount=data.contactcount;
			var groupcount=data.groupcount;
			var html="";
			if(contactcount==0){
				html="<dt ><a class='dis_sel'/>";
				html+="<a class='tipexpand'>所有订阅用户</a><span>[0]</span></dt>";
			}else{
				html="<dt><a class='no_sel'/>";
				html+="<b onclick='add_clipOpenClose(this)' class='tipexpand'>所有订阅用户</b><span>["+contactcount+"]</span></dt>";
				for(var i=0;i<data.contacts.length;i++){
					var contactobj=data.contacts[i];
					var cuid=contactobj.cuid;
					var cname=contactobj.cname;
					var cid=contactobj.cid;
					var cuserlogo=contactobj.cuserlogo;
					html+="<dd class='contactelement' uid='uid_"+cuid+"'>";
					html+="<div class='check'><input type='checkbox' uid='"+cuid+"' /><input type='hidden' value='"+cuid+"' class='uid'/></div>";
					html+="<img width=30 src='"+cuserlogo+"'>";
					html+="<div class='name'>"+cname+"</div>";
					html+="</dd>";
				}
			}
			jQ("#contact_friend").empty().append(html);
			var grouphtml="";
			if(groupcount==0){
				grouphtml="<li ><span class='info'>快去管理您的<a href='"+jQ("#ctxVal").val()+"/contact/group.html"+"'>分组</a>吧</span></li>";
			}else{
				for(var i=0;i<data.groups.length;i++){
					var groupobj=data.groups[i];
					var groupname=groupobj.groupname;
					var groupid=groupobj.groupid;
					var membercount=groupobj.membercount;
					var countstr;
					if(membercount>99){
						countstr=membercount+"+";
					}else{
						countstr=membercount;
					}
					var groupcontactlength=groupobj.mapcontacts.length; 
					if(groupcontactlength==0){
						grouphtml+="<li><dt><a class=\"dis_sel\"></a>";
					}else{
						grouphtml+="<li groupid="+groupid+"><dt><a class=\"no_sel\" ></a>";
					}
					grouphtml+="<b class=\"tipexpand close\" >"+groupname+"</b><span>["+countstr+"]</span></dt>";
					for(var j=0;j<groupobj.mapcontacts.length;j++){
						var mapcontactobj=groupobj.mapcontacts[j];
						var mcuid=mapcontactobj.cuid;
						for(var m=0;m<data.contacts.length;m++){
							var contactobj=data.contacts[m];
							var cuid=contactobj.cuid;
							var cname=contactobj.cname;
							var cid=contactobj.cid;
							var cuserlogo=contactobj.cuserlogo;
							if(mcuid==cuid){
								grouphtml+="<dd class='contactelement' uid='uid_"+cuid+"' style='display:none;'>";
								grouphtml+="<div class='check'><input type='checkbox' uid='"+cuid+"'/><input type='hidden' value='"+cuid+"' class='uid'/></div>";
								grouphtml+="<img width=30 src='"+cuserlogo+"'>";
								grouphtml+="<div class='name'>"+cname+"</div>";
								grouphtml+="</dd>";
							}
						}
					}
					grouphtml+="</li>";
				}
			}
			jQ("#inv_congroup").empty().append(grouphtml);
			jQ("#addclip_maincontent").data("userlistid","cclistcontent");
		}
	});
}

function initAddressSelection(){
	jQ.ajax({
		type: "POST",
		url: "userAjax!loadAllProvinces.action",
		success:function(data){
			if(data.result){
				jQ("#provinceselect").empty();
				var html="";
				html+="<option value='0' type='0'>";
				html+="请选择";
				html+="</option>";
				for(var i=0;i<data.provinces.length;i++){
					var province=data.provinces[i];
					var id=province.id;
					var name=province.name;
					var type=province.type;
					html+="<option value='"+id+"' type='"+type+"'>";
					html+=name;
					html+="</option>";
				}
				jQ("#provinceselect").append(html);
				jQ("#provinceselect").change(onProvincesSelect);
			}else{
				alert("数据出错");
			}
		}
	});
}

function onProvincesSelect(){

	var id=eval(jQ(this).val());
	var type=eval(jQ(this).find("option:selected").attr("type"));
	if(id==0){
		return;
	}else{
		if(type==-1){
			var name=jQ(this).find("option:selected").text();
			jQ("#cityselect").empty().append("<option type='-1' id='"+id+"'>"+name+"</option>");
			jQ.ajax({
				type: "POST",
				url: "userAjax!loadDistrict.action",
				data:{
					cityid:0,
					provinceid:id
				},
				success:function(data){
					if(data.result){
						jQ("#districtselect").empty();
						var html="";
						html+="<option value='0' type='0'>";
						html+="请选择";
						html+="</option>";
						for(var i=0;i<data.districts.length;i++){
							var districts=data.districts[i];
							var id=districts.id;
							var name=districts.name;
							var type=districts.type;
							html+="<option value='"+id+"' type='"+type+"'>";
							html+=name;
							html+="</option>";
						}
						jQ("#districtselect").append(html);
					}else{
						alert("数据出错");
					}
				}
			});
			return;
		}else{
			jQ.ajax({
				type: "POST",
				url: "userAjax!loadCityByProvinceid.action",
				data:{
					provinceid:id,
					type:type
				},
				success:function(data){
					if(data.result){
						jQ("#cityselect").empty();
						var html="";
						html+="<option value='0' type='0'>";
						html+="请选择";
						html+="</option>";
						for(var i=0;i<data.cities.length;i++){
							var city=data.cities[i];
							var cityid=city.id;
							var name=city.name;
							var type=city.type;
							html+="<option value='"+cityid+"' pid='"+id+"' type='"+type+"'>";
							html+=name;
							html+="</option>";
						}
						jQ("#cityselect").append(html);
						jQ("#cityselect").change(onCitesSelect);
					}else{
						alert("数据出错");
					}
				}
			});
		}
	}

}

function onCitesSelect(){
	var id=eval(jQ(this).val()); //cityid
	var pid=eval(jQ(this).find("option:selected").attr("pid"));
	jQ.ajax({
		type: "POST",
		url: "userAjax!loadDistrict.action",
		data:{
			cityid:id,
			provinceid:pid
		},
		success:function(data){
			if(data.result){
				jQ("#districtselect").empty();
				var html="";
				html+="<option value='0' type='0'>";
				html+="请选择";
				html+="</option>";
				for(var i=0;i<data.districts.length;i++){
					var districts=data.districts[i];
					var id=districts.id;
					var name=districts.name;
					var type=districts.type;
					html+="<option value='"+id+"' type='"+type+"'>";
					html+=name;
					html+="</option>";
				}
				jQ("#districtselect").append(html);
			}else{
				alert("数据出错");
			}
		}
	});
}

function initDatepicker(needdetailtime){
	if(needdetailtime){
		jQ("#clip_begindate_input").datepicker( "destroy" );
		jQ("#clip_enddate_input").datepicker( "destroy" );
		jQ("#clip_begindate_input").next().show();
		jQ("#clip_enddate_input").next().show();
		jQ("#clip_begindate_input").datepicker({
			yearRange : '1950:2020',
			dateFormat:'yy-mm-dd',
			changeMonth:true,
			changeYear:true,
			detailtime:true,
			beforeShow: function(i,e){  
				var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
				e.dpDiv.css('z-index', z);
				e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
			},
	        onClose: function(dateText,inst) {
	            var iobj=jQ("#clip_begindate_input").next();
	        	var hourval=eval(jQ(inst.dpDiv).find("div.detailtime").find("input.cliptimehour").val());
	        	if(hourval<10)
	        		hourval="0"+hourval;
	        	else if(hourval>23)
	        		hourval="00";
	        	var minval=eval(jQ(inst.dpDiv).find("div.detailtime").find("input.cliptimemin").val());
	        	if(minval<10)
	        		minval="0"+minval;
	        	else if(minval>59)
	        		minval="00";
	        	iobj.text(hourval+":"+minval);
	        	jQ( "#clip_enddate_input" ).datepicker( "option", "minDate", dateText );
	        }
	    });
		jQ("#clip_enddate_input").datepicker({
			yearRange : '1950:2020',
			dateFormat:'yy-mm-dd',
			changeMonth:true,
			changeYear:true,
			detailtime:true,
			beforeShow: function(i,e){  
				var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
				e.dpDiv.css('z-index', z);  
				e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
			},
	        onClose: function(dateText,inst) {
	            var iobj=jQ("#clip_enddate_input").next();
	        	var hourval=eval(jQ(inst.dpDiv).find("div.detailtime").find("input.cliptimehour").val());
	        	if(hourval<10)
	        		hourval="0"+hourval;
	        	else if(hourval>23)
	        		hourval="00";
	        	var minval=eval(jQ(inst.dpDiv).find("div.detailtime").find("input.cliptimemin").val());
	        	if(minval<10)
	        		minval="0"+minval;
	        	else if(minval>59)
	        		minval="00";
	        	iobj.text(hourval+":"+minval);
	        	jQ( "#clip_begindate_input" ).datepicker( "option", "maxDate", dateText );
	        }
	    });
	}else{
		jQ("#clip_begindate_input").datepicker( "destroy" );
		jQ("#clip_enddate_input").datepicker( "destroy" );
		jQ("#clip_begindate_input").next().hide();
		jQ("#clip_enddate_input").next().hide();
		jQ("#clip_begindate_input").datepicker({
			yearRange : '1950:2020',
			dateFormat:'yy-mm-dd',
			changeMonth:true,
			changeYear:true,
			detailtime:false,
			beforeShow: function(i,e){  
				var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
				e.dpDiv.css('z-index', z);
				e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
			},
	        onClose: function( selectedDate ) {
	            jQ( "#clip_enddate_input" ).datepicker( "option", "minDate", selectedDate );
	        }
	    });
		jQ("#clip_enddate_input").datepicker({
			yearRange : '1950:2020',
			dateFormat:'yy-mm-dd',
			changeMonth:true,
			changeYear:true,
			detailtime:false,
			beforeShow: function(i,e){  
				var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
				e.dpDiv.css('z-index', z);  
				e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
			},
	        onClose: function( selectedDate ) {
	            jQ( "#clip_begindate_input" ).datepicker( "option", "maxDate", selectedDate );
	        }
	    });
	}
}

function initClipdefaultcontent(){
	var html="";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='吃吃喝喝'></span>";
	html+="<b>";
	html+="吃吃喝喝";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='棋牌桌游'></span>";
	html+="<b>";
	html+="棋牌桌游";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='K歌娱乐'></span>";
	html+="<b>";
	html+="K歌娱乐";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='电影演出'></span>";
	html+="<b>";
	html+="电影演出";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='逛街血拼'></span>";
	html+="<b>";
	html+="逛街血拼";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='夜生活'></span>";
	html+="<b>";
	html+="夜生活";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='健身运动'></span>";
	html+="<b>";
	html+="健身运动";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='户外郊游'></span>";
	html+="<b>";
	html+="户外郊游";
	html+="</b>";
	html+="</p>";
	html+="<p>";
	html+="<span class='clipcheckbox' valref='美容养身'></span>";
	html+="<b>";
	html+="美容养身";
	html+="</b>";
	html+="</p>";
	jQ("#clipcontent_checkboxes").empty().append(html);
	jQ("#clipcontent_checkboxes>p>span.clipcheckbox").click(function(){
		jQ(this).toggleClass("clipcheckboxon");
	});
}

function onUploadpicChange(obj){
	var filename=jQ(obj).val();
	if(filename!=null&&filename.length>0){
		var fileext=filename.substr(filename.lastIndexOf(".")+1).toLowerCase();
		if(fileext=='jpg'||fileext=='jpeg'||fileext=='bmp'||fileext=='png'){
			jQ("div.preuploadinf").hide();
			jQ("div.inguploadinf a").unbind("click").bind("click",cancelUploadpic);
			jQ("div.inguploadinf").show();
			jQ("#addclipbutton").unbind("click").addClass("disableaddclip");
			jQ(obj).parent("form").submit();
		}
	}
}

function cancelUploadpic(){
	jQ.ajax({
		type: "POST",
		url:"eventAjax!cancelUploadClippic.action",
		success:function(data){
			if(data.result){
				jQ("div.inguploadinf a").unbind("click");
				jQ("div.inguploadinf").hide();
				jQ("div.preuploadinf").show();
				jQ("#addclipbutton").removeClass("disableaddclip").bind("click",addclip);
			}
		}
	});
	
}

function checkpicAndClose(obj){
	var picid=eval(jQ("#clipevent-picid").val()); 
	if(picid>0){
		jQ.ajax({
			type: "POST",
			url:"eventAjax!deleteUploadClippic.action",
			data:{
				picid:picid
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						jQ("div.preuploadinf").show();
						jQ("div.afteruploadinf").empty().hide();
					}
				}
			}
		});
	}
	jQ(obj).parent().next("textarea").val("");
	jQ(obj).parent().parent().hide();
	jQ("#ccmorecontent_btn a[affect='detail']").removeClass("on");
}

function cleanAndClose_deadlinetime(obj){
	jQ(obj).parent().next("input").val("");
	jQ(obj).parent().parent().hide();
	jQ("#ccmorecontent_btn a[affect='deadlinetime']").removeClass("on");
}

function cleanAndClose_address(obj){
	jQ("#provinceselect").val(0);
	var html="<option value='0'>请选择</option>";
	jQ("#cityselect").empty().append(html);
	jQ("#districtselect").empty().append(html);
	
	
	jQ(obj).parent().nextAll("input").val("");
	jQ(obj).parent().parent().hide();
	jQ("#ccmorecontent_btn a[affect='address']").removeClass("on");
}

function initClipAlert(){
	jQ("#addclip-showalert span.alerticon").unbind("click").bind("click",showalert);
	jQ("#addclip-hidealert span.alerticon").unbind("click").bind("click",hidealert);
}
function showalert(){
	jQ(this).parent().hide();
	jQ("#addclip-hidealert").fadeIn();
	jQ("#clipevent-alert").val(1);
	jQ("#alert_show_div").show();
	if(eval(jQ("#var_hasmobile").val())){
		jQ("#mobile_show_div_cbx").show().unbind("click").bind("click",function(){
			if(jQ(this).hasClass("mobile_mon")){
				jQ(this).removeClass("mobile_mon");
			}else
				jQ(this).addClass("mobile_mon");
		});
	}else{
		jQ("#mobile_show_div_cbx").hide();
	}
}

function hidealert(){
	jQ(this).parent().hide();
	jQ("#addclip-showalert").fadeIn();
	jQ("#clipevent-alert").val(0);
	jQ("#alert_show_div").hide();
	jQ("#alertdate_input").val("");
	jQ("#addclip-hidealert span.alertspan select").val(0);
}


function leavenotice(){
	return "";
}

function analyzeUrl(){
	var eventid=eval(getParameter("eventid"));
	if(isNaN(eventid)||eventid==null){
		jQ("div.deletecachefever").hide();
		jQ("#clip_cached_title").removeClass("onit");
		var year=eval(getParameter("year"));
		var month=eval(getParameter("month"));
		var day=eval(getParameter("day"));
		var hour=eval(getParameter("hour"));
		if(!isNaN(year)&&year!=null
				&&!isNaN(month)&&month!=null
				&&!isNaN(day)&&day!=null){
			var date=new Date();
			date.setFullYear(year,month-1,day);
			date.setMinutes(0,0,0);
			
			jQ("#clip_begindate_input").datepicker( "setDate",date );
			if(!isNaN(hour)&&hour!=null){
				jQ("#beginhour").val(hour);
			}else{
				jQ("#beginhour").val(0);
			}
		}
		
		jQ("#addcliptitleicon").removeClass("edittitle");
	}else{
		if(eventid==0){
			jQ("div.deletecachefever").hide();
			jQ("#clip_cached_title").removeClass("onit");
			loadEventDetail(eventid);
			return;
		}
		jQ("#clipevent-eventid").val(eventid);
		jQ("div.deletecachefever").show();
		jQ("#clip_cached_title").addClass("onit");
		jQ("div.deletecachefever").unbind("click").bind("click",function(){
			var info="";
			var title="";
			info="您确定舍弃该草稿么？";
			title="删除草稿";
			var eventid=eval(jQ("#clipevent-eventid").val());
			jQ("#viewopt_eventid").val(eventid);
			var opt=jQ("#viewopt");
			opt.bind("deleteEvent",deleteEvent);
			opt.data("function","deleteEvent")
			jQ("#viewopt_p").empty().append(info);
			jQ("#viewopt").dialog( "option", "title", title);
			jQ("#viewopt").parent().css('font', "14px \"Trebuchet MS\", sans-serif");
			jQ("#viewopt").dialog("open");
		});
//		jQ("#addclipbutton").addClass("confirmclip");
		jQ("#addcliptitleicon").addClass("edittitle");
		loadEventDetail(eventid);
	}
}

function loadCacheAndClockAndRecycleCount(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!loadCacheAndClockAndRecycleCount.action",
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					
					var alerttotalcount=dataObj.alerttotalcount;
					var memototalcount=dataObj.memototalcount;
					var invitetotalcount=dataObj.invitetotalcount;
					var cachetotalcount=dataObj.cachetotalcount;
					var recycletotalcount=dataObj.recycletotalcount;
					
					
					alerttotalcount=alerttotalcount>99?"99+":alerttotalcount;
					memototalcount=memototalcount>99?"99+":memototalcount;
					invitetotalcount=invitetotalcount>99?"99+":invitetotalcount;
					cachetotalcount=cachetotalcount>99?"99+":cachetotalcount;
					recycletotalcount=recycletotalcount>99?"99+":recycletotalcount;
					
					jQ("#memocount>span.count").empty().append(memototalcount);
					jQ("#invitecount>span.count").empty().append(invitetotalcount);
					jQ("#alertcount>span.count").empty().append(alerttotalcount);
					jQ("#cachecount>span.count").empty().append(cachetotalcount);
					jQ("#recyclecount>span.count").empty().append(recycletotalcount);
					
				}
			}
		}
	});
}

function loadUserMobileInfo(){
	jQ.ajax({
		type: "POST",
		url:"userAjax!isHasBindableMobile.action",
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.alertmethodnotice){
					//exist
					jQ("#alertmethodnotice").hide();
				}else{
					jQ("#alertmethodnotice").show();
					jQ("#alertmethodnotice div.close").unbind("click").bind("click",function(){
						var url="userAjax!cancelAlertMethodNotice.action";
						jQ.ajax({
							type: "POST",
							url:url,
							success:function(data){
								if(data!=null){
									var dataObj=eval("("+data+")");//转换为json对象
									if(dataObj['flag']){
										jQ("#alertmethodnotice").hide();
									}
								}
							}
						});
					});
				}
				if(eval(dataObj.flag)){
					jQ("#mobile_show_div_cbx").parent().show();
				}else{
					jQ("#mobile_show_div_cbx").parent().hide();
				}
			}
		}
	});
}

function deleteEvent(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					window.location.href=jQ("#ctxVal").val()+"/myclip/clip_cache.html";
				}
			}
		}
	});
}


function formateDetailTime(daytime){
	var temp=new Date();
	temp.setTime(eval(daytime));
	return temp.pattern("yyyy-MM-dd HH:mm");
}

function formateTitleTime(daytime){
	var temp=new Date();
	temp.setTime(eval(daytime));
	return temp.pattern("yyyy年MM月dd日");
}

function getTypeName(eng){
	if(eng=='other'){
		return "其他";
	}else if(eng=='work'){
		return "工作";
	}else if(eng=='socal'){
		return "社交";
	}else if(eng=='sect'){
		return "私人";
	}
}

function loadEventDetail(eventid){
	jQ("#addclip_maincontent").data("cliptype",3);
	jQ.ajax({
		type:"POST",
		url: "manageClipAjax!loadEventDetail.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data.result){
				jQ("#addclip_title").text("修改档期");
				var eventid=data.eventid;
				var title=data.title;
				var address=data.address;
				var content=data.content;
				var starttime=eval(data.starttime);
				var endtime=eval(data.endtime);
				var iswholeday=eval(data.iswholeday);
				var clipeventpic=data.clipeventpic;
				var deadlinetime=eval(data.deadlinetime);
				var sharemaps=data.sharemaps;
				var iscanfw=data.iscanfw;
				jQ("#clipevent-eventid").val(eventid);
				jQ("#clip-edit-eventid").val(eventid);
				jQ("#clip_title_input").val(title);
				
				var temp=new Date();
				if(starttime==0){
					jQ("#clip_begindate_input").val("");
				}else{
					temp.setTime(starttime);
					temp.setSeconds(0);	
					temp.setMilliseconds(0);
					var hourval,minval;
					hourval=temp.getHours();
					minval=temp.getMinutes();
					if(hourval<10)
		        		hourval="0"+hourval;
		        	else if(hourval>23)
		        		hourval="00";
					if(minval<10)
		        		minval="0"+minval;
		        	else if(minval>59)
		        		minval="00";
					jQ("#clip_begindate_input").next("b").empty().append(hourval+":"+minval);
					jQ("#clip_begindate_input").datepicker( "setDate",temp );
				}
				
				if(iswholeday){
					jQ("#clip_isoneday_cbx").data("checked",0).addClass("clipcheckboxon");
				}else{
					jQ("#clip_isoneday_cbx").data("checked",1).removeClass("clipcheckboxon");
					jQ("#clip_enddate_input").fadeIn();
					jQ("#clip_isoneday_cbx").prevAll("span.endtime").fadeIn();
					var temp2=new Date();
					if(endtime==0){
						jQ("#clip_enddate_input").val("");
					}else{
						temp2.setTime(endtime);
						temp2.setSeconds(0);	
						temp2.setMilliseconds(0);
						var hourval,minval;
						hourval=temp2.getHours();
						minval=temp2.getMinutes();
						if(hourval<10)
			        		hourval="0"+hourval;
			        	else if(hourval>23)
			        		hourval="00";
						if(minval<10)
			        		minval="0"+minval;
			        	else if(minval>59)
			        		minval="00";
						jQ("#clip_enddate_input").next("b").empty().append(hourval+":"+minval);
						jQ("#clip_enddate_input").datepicker( "setDate" ,temp2);
					}
				}
				
				if(deadlinetime>0){
					var temp2=new Date();
					temp2.setTime(deadlinetime);
					temp2.setSeconds(0);	
					temp2.setMilliseconds(0);
					var hourval,minval;
					hourval=temp2.getHours();
					minval=temp2.getMinutes();
					if(hourval<10)
		        		hourval="0"+hourval;
		        	else if(hourval>23)
		        		hourval="00";
					if(minval<10)
		        		minval="0"+minval;
		        	else if(minval>59)
		        		minval="00";
					jQ("#deadlinedate_input").next("input").val(hourval+":"+minval);
					jQ("#deadlinedate_input").datepicker( "setDate" ,temp2);
					jQ("#ccmorecontent_btn a[affect='deadlinetime']").addClass("on");
					jQ("#ccmorecontent_btn").nextAll("div.deadlinetime").show();
				}
				if(address!=null&&address.length>0){
					if(address.indexOf(":")>0){
						var addarray=address.split(":");
						if(addarray[0].indexOf("_")>0){
							var areaarray=addarray[0].split("_");
							var pid=eval(areaarray[0]);
							jQ("#provinceselect").val(pid);
							var cid=eval(areaarray[1]);
							if(cid>0){
								jQ.ajax({
									type: "POST",
									url: "userAjax!loadCityByProvinceid.action",
									data:{
										provinceid:pid,
										type:type
									},
									success:function(data){
										if(data.result){
											jQ("#cityselect").empty();
											var html="";
											html+="<option value='0' type='0'>";
											html+="请选择";
											html+="</option>";
											for(var i=0;i<data.cities.length;i++){
												var city=data.cities[i];
												var cityid=city.id;
												var name=city.name;
												var type=city.type;
												html+="<option value='"+cityid+"' pid='"+pid+"' type='"+type+"'>";
												html+=name;
												html+="</option>";
											}
											jQ("#cityselect").append(html);
											jQ("#cityselect").change(onCitesSelect);
											jQ("#cityselect").val(cid);
										}else{
											alert("数据出错");
										}
									}
								});
								var did=0;
								if(areaarray.length>2)
									did=eval(areaarray[2]);
								
								jQ.ajax({
									type: "POST",
									url: "userAjax!loadDistrict.action",
									data:{
										cityid:cid,
										provinceid:pid
									},
									success:function(data){
										if(data.result){
											jQ("#districtselect").empty();
											var html="";
											html+="<option value='0' type='0'>";
											html+="请选择";
											html+="</option>";
											for(var i=0;i<data.districts.length;i++){
												var districts=data.districts[i];
												var id=districts.id;
												var name=districts.name;
												var type=districts.type;
												html+="<option value='"+id+"' type='"+type+"'>";
												html+=name;
												html+="</option>";
											}
											jQ("#districtselect").append(html);
											jQ("#districtselect").val(did);
										}else{
											alert("数据出错");
										}
									}
								});
								
							}else{
								var ptxt=jQ("#provinceselect option:selected").text();
								jQ("#cityselect").empty().append("<option value=0>"+ptxt+"</option>");
								var did=0;
								if(areaarray.length>2)
									did=eval(areaarray[2]);


								jQ.ajax({
									type: "POST",
									url: "userAjax!loadDistrict.action",
									data:{
										cityid:cid,
										provinceid:pid
									},
									success:function(data){
										if(data.result){
											jQ("#districtselect").empty();
											var html="";
											html+="<option value='0' type='0'>";
											html+="请选择";
											html+="</option>";
											for(var i=0;i<data.districts.length;i++){
												var districts=data.districts[i];
												var id=districts.id;
												var name=districts.name;
												var type=districts.type;
												html+="<option value='"+id+"' type='"+type+"'>";
												html+=name;
												html+="</option>";
											}
											jQ("#districtselect").append(html);
											jQ("#districtselect").val(did);
										}else{
											alert("数据出错");
										}
									}
								});
								
							}
						}else{
							var pid=eval(addarray[0]);
							jQ("#provinceselect").val(pid);
							var type=eval(jQ("#provinceselect").find("option:selected").attr("type"));
							if(type==-1){
								var name=jQ("#provinceselect").find("option:selected").text();
								jQ("#cityselect").empty().append("<option type='-1' id='"+pid+"' value=0>"+name+"</option>");
								jQ.ajax({
									type: "POST",
									url: "userAjax!loadDistrict.action",
									data:{
										cityid:0,
										provinceid:pid
									},
									success:function(data){
										if(data.result){
											jQ("#districtselect").empty();
											var html="";
											html+="<option value='0' type='0'>";
											html+="请选择";
											html+="</option>";
											for(var i=0;i<data.districts.length;i++){
												var districts=data.districts[i];
												var id=districts.id;
												var name=districts.name;
												var type=districts.type;
												html+="<option value='"+id+"' type='"+type+"'>";
												html+=name;
												html+="</option>";
											}
											jQ("#districtselect").append(html);
										}else{
											alert("数据出错");
										}
									}
								});
							}else{
								jQ.ajax({
									type: "POST",
									url: "userAjax!loadCityByProvinceid.action",
									data:{
										provinceid:id,
										type:type
									},
									success:function(data){
										if(data.result){
											jQ("#cityselect").empty();
											var html="";
											html+="<option value='0' type='0'>";
											html+="请选择";
											html+="</option>";
											for(var i=0;i<data.cities.length;i++){
												var city=data.cities[i];
												var cityid=city.id;
												var name=city.name;
												var type=city.type;
												html+="<option value='"+cityid+"' pid='"+id+"' type='"+type+"'>";
												html+=name;
												html+="</option>";
											}
											jQ("#cityselect").append(html);
											jQ("#cityselect").change(onCitesSelect);
										}else{
											alert("数据出错");
										}
									}
								});
							}
						}
						jQ("#address_ext_ipt").val(addarray[1]);
					}else{
						jQ("#address_ext_ipt").val(address);
					}
					jQ("#ccmorecontent_btn a[affect='address']").addClass("on");
					jQ("#ccmorecontent_btn").nextAll("div.address").show();
				}
				if((content!=null&&content.length>0)||clipeventpic.length>0){
					if(content!=null&&content.length>0){
						var reg=new RegExp("<br>","g");
						content = content.replace(reg,"\r\n");
						jQ("#clipcc_content_area").val(content);
					}
					if(clipeventpic.length>0){
						jQ("#clipevent-picid").val(eval(data.clipeventpicid));
						jQ("div.preuploadinf").hide();
						jQ("div.inguploadinf").hide();
						var html="";
						html+="<img src='"+jQ("#ctxVal").val()+"/clippic/S_"+clipeventpic+"' onload='resizeImg(this)' style='display:none;'>";
						html+="<a title='删除图片'></a>";
						jQ("div.afteruploadinf").empty().append(html).show();
						jQ("div.afteruploadinf a").unbind("click").bind("click",deleteUploadClippic);
					}
					jQ("#ccmorecontent_btn a[affect='detail']").addClass("on");
					jQ("#ccmorecontent_btn").nextAll("div.detail").show();
				}
				if(sharemaps.length>0){
					for(var i=0;i<sharemaps.length;i++){
						var mapobj=sharemaps[i];
						var share2uid=eval(mapobj.share2uid);
						if(share2uid==0){
							break;
						}else{
							jQ("div.snsasync").hide();
							jQ("div.laststepdiv div.optitem").css({ "margin-left": "-128px"});
							jQ("#addclip_asyncweibo").data("asyncsina",0);
							var bbtn=jQ("#usertype2share div.choose b.clipradiobtn");
							if(!bbtn.eq(1).hasClass("clipradiobtnon")){
								bbtn.removeClass("clipradiobtnon");
								bbtn.eq(1).addClass("clipradiobtnon");
								bbtn.eq(1).nextAll("a").show().bind("click",showContactDetailTip);
								if(!eval(iscanfw))
									jQ("#iscanfwbox span.clipcheckbox").removeClass("clipcheckboxon");
								jQ("#iscanfwbox span.clipcheckbox").unbind("click").bind("click",function(){
									jQ(this).toggleClass("clipcheckboxon");
								});
								jQ("#iscanfwbox").show();
							}
							jQ("#contact_friend dd").each(function(){
								var uid=eval(jQ(this).find("div.check").find("input.uid").val());
								if(share2uid==uid){
									var name=jQ(this).find("div.name").text();
									showQuickContact(1,uid,name,null,0);
								}
							});
						}
					}
				}
				jQ("#deletetempclipbtn").show();
				jQ("#deletetempclipbtn").bind("click",deleteEvent);
			}else{
				clip_tips(data.errormsg);
				window.location.href=jQ("#ctxVal").val()+"/myclip/add_clip.html";
			}
			
		}
	});
}

/*
function serAlertShow(obj){
	if(jQ(obj).hasClass("expend_on")){
		jQ("#alert_show_div").slideToggle();
		jQ(obj).removeClass("expend_on");
	}else{
		jQ("#alert_show_div").slideToggle();
		jQ(obj).addClass("expend_on");
		
	}
}*/

function serContactsShow(obj){
	if(jQ(obj).attr("checked")){
		jQ("#contact_show_div").slideToggle();
	}else{
		jQ("#contact_show_div").slideToggle();
		
	}
}

function serDetailsShow(obj){
	if(jQ(obj).hasClass("expend_on")){
		jQ("#detail_show_div").slideToggle();
		jQ(obj).removeClass("expend_on");
	}else{
		jQ("#detail_show_div").slideToggle();
		jQ(obj).addClass("expend_on");
		
	}
}

function serSharesShow(obj){
	if(jQ(obj).attr("checked")){
		jQ("#share_show_div").fadeIn();
	}else{
		jQ("#share_show_div").fadeOut();
		
	}
}

function initContacts(){
	jQ.ajax({
		type:"POST",
		url: "contactAjax!loadContactAll.action",
		success:function(data){
			if(data.result){
				add_clipCreateContentHtml(data);
			}else{
				alert(data.errormsg);
			}
		}
	});
}

function showQuickContactGroup(id,name,membercount,listobj){
	var flag=false;
	if(listobj.css("display")=="none"){
		flag=true;
	}
	var canbeadd=true;
	jQ("li",listobj).each(function(){
		var groupid=eval(jQ(this).attr("groupid"));
		if(groupid==eval(id)){
			canbeadd=false;
			return false;
		}
	});
	if(!canbeadd)
		return;
	var countstr;
	if(membercount>99){
		countstr=membercount+"+";
	}else{
		countstr=membercount;
	}
	var html="<li groupid='"+id+"'>";
	html+="<span class=\"groupicon\"></span>";
	html+="<span class=\"groupname\">"+name+"</span>";
	html+="<span class=\"groupcount\">["+countstr+"]</span>";
	html+="<a class=\"gclose\" onclick='deleteContactGroup(this);'></a></li>";
	listobj.append(html);
	if(listobj.css("display")=="none"){
		listobj.show();
	}
}

function showQuickContact(isNormal,id,name,email,hasmobile){
	var listobj=jQ("#"+jQ("#addclip_maincontent").data("userlistid"));
	if(listobj.length<=0)
		listobj=jQ("#listcontent");
	if(isNormal){
		var flag=false;
		if(listobj.css("display")=="none"){
			flag=true;
		}
		var canbeadd=true;
		jQ("li",listobj).each(function(){
			var uid=eval(jQ("span.name",this).attr("uid"));
			if(uid==eval(id)){
				canbeadd=false;
				return false;
			}
		});
		if(!canbeadd)
			return;
		var html="<li class='contact' uid='uid_"+id+"'>";
		html+="<span class='name' title='"+name+"' uid='"+id+"'>"+name+"</span>";
		html+="<div class='opt'>";
		html+="<a class='email emailonit' title='邮件通知'></a>";
		if(eval(hasmobile))
			html+="<a class='mobilemsg' title='短信通知' onclick='changeMobileStatus(this);'></a>";
		html+="<a class='close' onclick='deleteContact(this);'></a></div></li>";
		listobj.append(html);
		if(flag)
			listobj.show();
		
	}
}

function showQuickContact2(isNormal,id,name,email,hasmobile){
	if(isNormal){
		var flag=false;
		if(jQ("#inviteuserautolist").css("display")=="none"){
			flag=true;
		}
		var canbeadd=true;
		jQ("li",jQ("#inviteuserautolist")).each(function(){
			var uid=eval(jQ("span.name",this).attr("uid"));
			if(uid==eval(id)){
				canbeadd=false;
				return false;
			}
		});
		if(!canbeadd)
			return;
		var html="<li class='contact' uid='uid_"+id+"'>";
		html+="<span class='name' title='"+email+"' uid='"+id+"'>"+name+"</span>";
		html+="<div class='opt'>";
		html+="<a class='email emailonit' title='邮件通知'></a>";
		if(eval(hasmobile))
			html+="<a class='mobilemsg' title='短信通知' onclick='changeMobileStatus(this);'></a>";
		html+="<a class='close' onclick='deleteContact(this);'></a></div></li>";
		jQ("#inviteuserautolist").append(html);
		if(flag)
			jQ("#inviteuserautolist").show();
		
	}
}

function changeMobileStatus(obj){
	if(jQ(obj).hasClass("mobilemsgonit")){
		jQ(obj).data("mobilenotice",0);
		jQ(obj).removeClass("mobilemsgonit");
	}else{
		jQ(obj).data("mobilenotice",1);
		jQ(obj).addClass("mobilemsgonit");
	}
}

function deleteContact(obj){
	var liobj=jQ(obj).parent().parent();
	var uid=jQ(obj).parent().prev().attr("uid");
	var listobj=liobj.parent();
	liobj.remove();
	if(jQ("li",listobj).length==0){
		listobj.hide();
	}
	
	jQ("#inv_congroup li dd[uid='uid_"+uid+"'] div.check input:checkbox").attr("checked",false);
	jQ("#contact_friend dd[uid='uid_"+uid+"'] div.check input:checkbox").attr("checked",false);
	checkAllGroupList(false);
	checkAllContacList(false);
}



function deleteContactGroup(obj){
	var liobj=jQ(obj).parent();
	var listobj=liobj.parent();
	var groupid=liobj.attr("groupid");
	liobj.remove();
	if(jQ("li",listobj).length==0){
		listobj.hide();
	}
	jQ("#inv_congroup li[groupid="+groupid+"] dt a").removeClass().addClass("no_sel");
}

function showGroupDetailTip(obj){
	var listobj=jQ("#"+jQ("#addclip_maincontent").data("userlistid"));
	if(listobj.length<=0)
		listobj=jQ("#listcontent");
	if(jQ("#addclipcontactlist").css("display")=="none"){
		jQ("#addclipcontactmbtab span:first").hide();
		jQ("#addclipcontactmbtab span:last").removeClass().addClass("onit");
		jQ("#contact").hide();
		jQ("#inv_congroup li dt b.tipexpand").addClass("hidebg");
		jQ("#inv_congroup li dd").hide();
		jQ("#inv_congroup").show();
		jQ("#inv_congroup li dt a[class!='dis_sel']").removeClass().addClass("no_sel");
		if(listobj.find("li.group").length>0){
			listobj.find("li.group").each(function(){
				var groupid=jQ(this).attr("groupid");
				jQ("#inv_congroup li[groupid="+groupid+"] dt a").removeClass().addClass("all_sel");
				
			});
		}
		var box = jQ(obj).offset();
		jQ("#addclipcontactlist").css({"top":box.top-40,"left":box.left+30}).show();
		jQ("#addclipcontactlist").show();
		jQ("#inv_congroup li dt a").unbind("click").bind("click",synchronize2ulgrouplist);
		
	}else{
		jQ("#addclipcontactlist").hide();
	}
}

function synchronize2ulgrouplist(){
	var listobj=jQ("#"+jQ("#addclip_maincontent").data("userlistid"));
	if(listobj.length<=0)
		listobj=jQ("#listcontent");
	var liobj=jQ(this).parent().parent();
	if(jQ(this).hasClass("all_sel")){
		jQ(this).removeClass().addClass("no_sel");
		var groupid=liobj.attr("groupid");
		listobj.find("li.group[groupid="+groupid+"]").remove();
		if(listobj.find("li").length==0){
			listobj.hide();
		}
	}else if(jQ(this).hasClass("no_sel")){
		jQ(this).removeClass().addClass("all_sel");
		var groupid=liobj.attr("groupid");
		if(listobj.find("li.group[groupid="+groupid+"]").length>0)
			return;
		var name=jQ(this).nextAll("b.tipexpand").text();
		var countstr=jQ(this).nextAll("span").text();
		var html="<li class='group' groupid='"+groupid+"'>";
		html+="<span class=\"groupicon\"></span>";
		html+="<span class=\"groupname\">"+name+"</span>";
		html+="<span class=\"groupcount\">"+countstr+"</span>";
		html+="<a class=\"gclose\" onclick='deleteContactGroup(this);'></a></li>";
		listobj.append(html);
		listobj.show();
	}
}

function synchronizegrouplist(event){
	var listobj=event.data.listobj;
	var curobj=jQ(event.currentTarget);
	var groupid=eval(curobj.attr("groupid"));
	var groupname=curobj.next().text();
	var membercount=curobj.attr("membercount");
	if(eval(curobj.attr("checked"))){
		showQuickContactGroup(groupid,groupname,membercount,listobj);
	}else{
		removeContactGrouparea(groupid,listobj);
	}
}

function showContactDetailTip(obj){
	var listobj=jQ("#"+jQ("#addclip_maincontent").data("userlistid"));
	if(listobj.length<=0)
		listobj=jQ("#listcontent");
	if(typeof(obj)=='undefined')
		obj=obj.currentTarget;
	else if(!jQ(obj).hasClass("sharegroupicon"))
		obj=jQ(this);
	if(jQ("#addclipcontactlist").css("display")=="none"){
		jQ("#addclipcontactmbtab span:first").removeClass().addClass("onit").show();
		jQ("#addclipcontactmbtab span:last").removeClass().addClass("nor");
		jQ("#contact").show();
		jQ("#inv_congroup li dt b.tipexpand").removeClass("hidebg");
		jQ("#inv_congroup li dt b.tipexpand").unbind("click").bind("click",add_clipOpenClose2);
		
		jQ("#contact_friend dt a:first").attr("class","no_sel");
		jQ("#inv_congroup").hide();
		jQ("#inv_congroup li dt a[class!='dis_sel']").removeClass().addClass("no_sel");
		jQ("#inv_congroup li dd div.check  input:checkbox").attr("checked",false);
		jQ("#contact_friend dd div.check  input:checkbox").attr("checked",false);
		var contactlength=listobj.find("li.contact").length;
		if(contactlength>0){
			if(jQ("#contact_friend dd").length==contactlength){
				jQ("#contact_friend dt a[class!='dis_sel']").removeClass().addClass("all_sel");
			}
			listobj.find("li.contact").each(function(){
				var uid=jQ(this).attr("uid");
				jQ("#contact_friend dd[uid='"+uid+"'] div.check input:checkbox").attr("checked",true);
				jQ("#inv_congroup li dd[uid='"+uid+"'] div.check input:checkbox").attr("checked",true);
			});
			checkAllGroupList(true);
			checkAllContacList(true);
		}
		var box = jQ(obj).offset();
		jQ("#addclipcontactlist").css({"top":box.top-40,"left":box.left+30}).show();
		jQ("#addclipcontactlist").show();
		
		jQ("#contact_friend dt a").unbind("click").bind("click",selAllsynchronizecontactlistOnContact);
		jQ("#contact_friend dd input:checkbox").unbind("click").bind("click",synchronizecontactlistOnContact);
		jQ("#inv_congroup li dt a").unbind("click").bind("click",selAllsynchronizecontactlistOnGroup);
		jQ("#inv_congroup dd.contactelement input:checkbox").unbind("click").bind("click",synchronizecontactlistOnGroup);
	}else{
		jQ("#addclipcontactlist").hide();
	}
	
}

function selAllsynchronizecontactlistOnGroup(event){
	if(jQ(this).hasClass("dis_sel"))
		return;
	if(jQ(this).hasClass("all_sel")){
		jQ(this).parent().nextAll("dd").each(function(){
			var checkboxobj=jQ(this).find("div.check").find("input:checkbox");
			if(eval(checkboxobj.attr("checked"))==true){
				checkboxobj.attr("checked",false);
				var uid=checkboxobj.nextAll("input.uid").val();
				removeContactarea(uid);
				jQ("#inv_congroup li dd[uid='uid_"+uid+"'] div.check input:checkbox[checked=true]").attr("checked",false);
				jQ("#contact_friend dd[uid='uid_"+uid+"'] div.check input:checkbox[checked=true]").attr("checked",false);
			}
		});
		checkAllGroupList(false);
		checkAllContacList(false);
	}else{
		jQ(this).parent().nextAll("dd").each(function(){
			var checkboxobj=jQ(this).find("div.check").find("input:checkbox");
			if(eval(checkboxobj.attr("checked"))==false){
				checkboxobj.attr("checked",true);
				var uid=checkboxobj.nextAll("input.uid").val();
//				var hasmobile=checkboxobj.nextAll("input.hasmobile").val();
				var name=checkboxobj.parent().nextAll("div.name").text();
//				var email=checkboxobj.parent().nextAll("div.email_add").text();
				showQuickContact(1,uid,name,null,0);
				
				jQ("#inv_congroup li dd[uid='uid_"+uid+"'] div.check input:checkbox[checked=false]").attr("checked",true);
				jQ("#contact_friend dd[uid='uid_"+uid+"'] div.check input:checkbox[checked=false]").attr("checked",true);
			}
		});
		checkAllGroupList(true);
		checkAllContacList(true);
	}
}

function checkAllContacList(ischecktrue){
	if(jQ("#contact_friend dd").length==0)
		return;
	if(ischecktrue){
		if(jQ("#contact_friend dd").find("div.check").find("input:checkbox[checked=true]").length==jQ("#contact_friend dd").length){
			jQ("#contact_friend dt").find("a").removeClass().addClass("all_sel");
		}else{
			if(jQ("#contact_friend dd").find("div.check").find("input:checkbox[checked=true]").length>0)
				jQ("#contact_friend dt").find("a").removeClass().addClass("half_sel");
		}
	}else{
		if(jQ("#contact_friend dd").find("div.check").find("input:checkbox[checked=false]").length==jQ("#contact_friend dd").length){
			jQ("#contact_friend dt").find("a").removeClass().addClass("no_sel");
		}else{
			if(jQ("#contact_friend dd").find("div.check").find("input:checkbox[checked=false]").length>0)
				jQ("#contact_friend dt").find("a").removeClass().addClass("half_sel");
		}
	}
}

function checkAllGroupList(ischecktrue){
	if(ischecktrue){
		jQ("#inv_congroup li").each(function(){
			if(!jQ(this).find("dt").find("a").hasClass("dis_sel")){
				if(jQ(this).find("dd").find("div.check").find("input:checkbox[checked=true]").length==jQ(this).find("dd").length){
					jQ(this).find("dt").find("a").removeClass().addClass("all_sel");
				}else{
					if(jQ(this).find("dd").find("div.check").find("input:checkbox[checked=true]").length>0)
						jQ(this).find("dt").find("a").removeClass().addClass("half_sel");
				}
			}
		});
	}else{
		jQ("#inv_congroup li").each(function(){
			if(!jQ(this).find("dt").find("a").hasClass("dis_sel")){
				if(jQ(this).find("dd").find("div.check").find("input:checkbox[checked=false]").length==jQ(this).find("dd").length){
					jQ(this).find("dt").find("a").removeClass().addClass("no_sel");
				}else{
					if(jQ(this).find("dd").find("div.check").find("input:checkbox[checked=false]").length>0)
						jQ(this).find("dt").find("a").removeClass().addClass("half_sel");
				}
			}
		});
	}
}

function selAllsynchronizecontactlistOnContact(event){
	if(jQ(this).hasClass("dis_sel"))
		return;
	if(jQ(this).hasClass("all_sel")){
		jQ("#contact_friend dd div.check input:checkbox[checked=true]").each(function(){
			jQ(this).attr("checked",false);
			var uid=jQ(this).nextAll("input.uid").val();
			jQ("#inv_congroup li dd[uid='uid_"+uid+"'] div.check").find("input:checkbox[checked=true]").attr("checked",false);
			removeContactarea(uid);
		});
		checkAllGroupList(false);
		jQ(this).removeClass().addClass("no_sel");
	}else{
		jQ("#contact_friend dd div.check input:checkbox[checked=false]").each(function(){
			jQ(this).attr("checked",true);
			var uid=jQ(this).nextAll("input.uid").val();
//			var hasmobile=jQ(this).nextAll("input.hasmobile").val();
			var name=jQ(this).parent().nextAll("div.name").text();
//			var email=jQ(this).parent().nextAll("div.email_add").text();
			jQ("#inv_congroup li dd[uid='uid_"+uid+"'] div.check").find("input:checkbox[checked=false]").attr("checked",true);
			showQuickContact(1,uid,name,null,0);
		});
		checkAllGroupList(true);
		jQ(this).removeClass().addClass("all_sel");
	}
}

function synchronizecontactlistOnContact(event){
	var cbxobj=jQ(this);
	var cbxval=eval(cbxobj.attr("checked"));
	var uid=cbxobj.nextAll("input.uid").val();
	var hasmobile=cbxobj.nextAll("input.hasmobile").val();
	var name=cbxobj.parent().nextAll("div.name").text();
	var email=cbxobj.parent().nextAll("div.email_add").text();
	if(cbxval){
		showQuickContact(1,uid,name,email,hasmobile);
		jQ("#inv_congroup li dd[uid=uid_"+uid+"] div.check input:checkbox").attr("checked",true);
		checkAllContacList(true);
		checkAllGroupList(true);
	}else{
		removeContactarea(uid);
		jQ("#inv_congroup li dd[uid=uid_"+uid+"] div.check input:checkbox").attr("checked",false);
		checkAllContacList(false);
		checkAllGroupList(false);
	}
}

function synchronizecontactlistOnGroup(event){
	var cbxobj=jQ(this);
	var cbxval=eval(cbxobj.attr("checked"));
	var uid=cbxobj.nextAll("input.uid").val();
//	var hasmobile=cbxobj.nextAll("input.hasmobile").val();
	var name=cbxobj.parent().nextAll("div.name").text();
//	var email=cbxobj.parent().nextAll("div.email_add").text();
	if(cbxval){
		jQ("#inv_congroup li dd[uid='uid_"+uid+"'] div.check").find("input:checkbox[checked=false]").attr("checked",true);
		jQ("#contact_friend dd input:checkbox[uid="+uid+"]").attr("checked",true);
		showQuickContact(1,uid,name,null,0);
		checkAllGroupList(true);
		checkAllContacList(true);
	}else{
		jQ("#inv_congroup li dd[uid='uid_"+uid+"'] div.check").find("input:checkbox[checked=true]").attr("checked",false);
		jQ("#contact_friend dd input:checkbox[uid="+uid+"]").attr("checked",false);
		removeContactarea(uid);
		checkAllGroupList(false);
		checkAllContacList(false);
	}
}

function add_clipCreateContentHtml(data){
	var contactcount=data.contactcount;
	var html="";
	if(contactcount==0){
		html="<dt ><a class='dis_sel'/>";
		html+="<a class='tipexpand'>所有联系人</a><span>[0]</span></dt>";
	}else{
		var invites=getParameter("invites");
		var defaultuserlist=new Array();
		if(invites!=null&&typeof(invites)!='undefined'&&invites.length>0){
			jQ("#thirdstepchoose b:last").click();
			if(invites.indexOf(",")>0){
				var arr=invites.split(",");
				for(var i=0;i<arr.length;i++){
					defaultuserlist.push(eval(arr[i]));
				}
			}else{
				defaultuserlist.push(eval(invites));
			}
		}
		html="<dt><a class='no_sel'/>";
		html+="<b onclick='add_clipOpenClose(this)' class='tipexpand'>所有联系人</b><span>["+contactcount+"]</span></dt>";
		for(var i=0;i<data.contacts.length;i++){
			var contactobj=data.contacts[i];
			var cuid=contactobj.uid;
			var name=contactobj.name;
			var hasmobile=contactobj.hasmobile;
			var logo=contactobj.logo;
			if(defaultuserlist.length>0){
				for(var j=0;j<defaultuserlist.length;j++){
					var tmp=defaultuserlist[j];
					if(cuid==tmp){
						showQuickContact(true,cuid,name,null,hasmobile);
					}
				}
			}
			html+="<dd class='contactelement' uid='uid_"+cuid+"'>";
			html+="<div class='check'>" +
					"<input type='checkbox' uid='"+cuid+"' />" +
					"<input type='hidden' value='"+cuid+"' class='uid'/>" +
					"<input type='hidden' value='"+hasmobile+"' class='hasmobile'/></div>";
			html+="<img src='"+logo+"'>";
			html+="<div class='name'>"+name+"</div>";
			html+="</dd>";
		}
	}
	jQ("#contact_friend").empty().append(html);
	var grouphtml="";
	var grouplength=data.groupcount;
	if(grouplength==0){
		grouphtml="<li ><span class='info'>快去管理您的<a href='"+jQ("#ctxVal").val()+"/contact/group.html"+"'>群组</a>吧</span></li>";
	}else{
		for(var i=0;i<data.groups.length;i++){
			var groupobj=data.groups[i];
			var groupname=groupobj.groupname;
			var groupid=groupobj.groupid;
			var membercount=groupobj.membercount;
			var countstr;
			if(membercount>99){
				countstr=membercount+"+";
			}else{
				countstr=membercount;
			}
			
			if(membercount==0){
				grouphtml+="<li><dt><a class=\"dis_sel\"></a>";
			}else{
				grouphtml+="<li groupid="+groupid+"><dt><a class=\"no_sel\" ></a>";
			}
			grouphtml+="<b class=\"tipexpand close\" >"+groupname+"</b><span>["+countstr+"]</span></dt>";
			for(var j=0;j<groupobj.sharemaps.length;j++){
				var sharemapobj=groupobj.sharemaps[j];
				var muid=sharemapobj.muid;
				for(var m=0;m<data.contacts.length;m++){
					var contactobj=data.contacts[m];
					var cuid=contactobj.uid;
					if(cuid==muid){
						var name=contactobj.name;
						var hasmobile=contactobj.hasmobile;
						var logo=contactobj.logo;
						grouphtml+="<dd class='contactelement' uid='uid_"+cuid+"' style='display:none;'>";
						grouphtml+="<div class='check'><input type='checkbox' uid='"+cuid+"'/><input type='hidden' value='"+cuid+"' class='uid'/><input type='hidden' value='"+hasmobile+"' class='hasmobile'/></div>";
						grouphtml+="<img src='"+logo+"'>";
						grouphtml+="<div class='name'>"+name+"</div>";
						grouphtml+="</dd>";
					}
				}
			}
			grouphtml+="</li>";
		}
	}
	jQ("#inv_congroup").empty().append(grouphtml);
	jQ("#addclip_maincontent").data("userlistid","listcontent");
}

function removeContactarea(uid){
	var listobj=jQ("#"+jQ("#addclip_maincontent").data("userlistid"));
	if(listobj.length<=0)
		listobj=jQ("#listcontent");
	listobj.find("li[uid=uid_"+uid+"]").remove();
	if(jQ("li",listobj).length==0){
		listobj.hide();
	}
}

function removeContactGrouparea(groupid,listobj){
	jQ(listobj).find("li[groupid="+groupid+"]").remove();
	if(jQ("li",listobj).length==0){
		listobj.hide();
	}
}

function add_clipOpenClose2(){
	if(!jQ(this).prev().hasClass("dis_sel")){
		jQ(this).parent().nextAll().slideToggle('fast');
		jQ(this).toggleClass('close');
	}
}

function add_clipOpenClose(obj){
	jQ(obj).parent().nextAll().slideToggle('fast');
	jQ(obj).toggleClass('close');
	//jQ(obj).find('ol:first').toggleClass('frist_on').toggleClass('frist_off');
}


function addclip(){
	var status=1;
	if(checkClipData(1)){
		if(status==0){
			var info="";
			var title="";
			info="存为草稿将不会为您保存设置的提醒时间及邀请的联系人，是否继续？";
			title="提醒";
			var opt=jQ("#viewopt");
			opt.bind("saveTemp",saveTemp);
			opt.data("function","saveTemp")
			jQ("#viewopt_p").empty().append(info);
			jQ("#viewopt").dialog( "option", "title", title);
			jQ("#viewopt").parent().css('font', "14px \"Trebuchet MS\", sans-serif");
			jQ("#viewopt").dialog("open");
		}else{
			jQ("#loadingui").show();
			setTimeout(function(){
				submitClipData(status);
				return true;
			},1500);
		}
	}
	
	
	
}

function saveTemp(){
	if(checkClipData(1))
		submitClipData(0);
}

function submitClipData(status){
	var cliptype=eval(jQ("#addclip_maincontent").data("cliptype"));
	var usertype=eval(jQ("#var_usertype").val());
	if(usertype==2)
		cliptype=3;
	var eventid=eval(jQ("#clipevent-eventid").val());
	var title="";
	if(jQ.trim(jQ("#clip_title_input").val())!=null&&jQ.trim(jQ("#clip_title_input").val()).length>0){
		title=jQ.trim(jQ("#clip_title_input").val());
		title=title.replace(/\n/g,"");
		title=title.replace(/\r.\n/g,"");
		title=htmlData(title);
	}
	if(cliptype==3||cliptype==4){
		if(jQ("#clipcontent_checkboxes>p>span.clipcheckboxon").length>0){
			var contentlist="";
			jQ("#clipcontent_checkboxes>p>span.clipcheckboxon").each(function(i){
				if(i==0){
					contentlist+=jQ(this).attr("valref");
				}else{
					contentlist+=" "+jQ(this).attr("valref");
				}
			});
			if(title.length>0){
				title=contentlist+" 补充："+title;
			}else{
				title=contentlist;
			}
		}
	}
	
	var begindate=jQ("#clip_begindate_input").datepicker( "getDate" );
	var beginlong=0;
	if(begindate!=null){
		if(usertype==2||cliptype==1){
			var iobjtext=jQ.trim(jQ("#clip_begindate_input").next().text());
			var tmparr=iobjtext.split(":");
			begindate.setHours(eval(tmparr[0]));
			begindate.setMinutes(eval(tmparr[1]));
		}
		beginlong=begindate.getTime();
	}
	
	var endlong=0;
	var iswholeday=1;
	if(jQ("#clip_isoneday_cbx").data("checked")&&cliptype!=2){
		iswholeday=0;
		var enddate=jQ("#clip_enddate_input").datepicker( "getDate" );
		if(enddate!=null){
			if(usertype==2||cliptype==1){
				var iobjtext=jQ.trim(jQ("#clip_enddate_input").next().text());
				var tmparr=iobjtext.split(":");
				enddate.setHours(eval(tmparr[0]));
				enddate.setMinutes(eval(tmparr[1]));
			}
			var endlong=enddate.getTime();
		}
	}
	var address='';
	var alertlong=0;
	var deadlinelong=0;
	var mobilenum=0;
	var mlist='';
//	var eventtype=jQ("#eventtype_select").val();
	var share2userlist='';
	var iscanfw=1;
//	if(eval(jQ("#var_hasmobile").val())){
//		if(eval(jQ("#clip_alertdate_input").data("mobilenotice"))){
//			mobilenum=1;
//		}
//	}
	
	var contentArea="";
	if(usertype==2){
		if(jQ("#ccmorecontent_btn a[affect='detail']").hasClass("on")){
			contentArea=jQ.trim(jQ('#clipcc_content_area').val());
		}
		if(jQ("#ccmorecontent_btn a[affect='address']").hasClass("on")){
			var pre_address=getPreAddress();
			var suf_address=jQ.trim(jQ("#address_ext_ipt").val());
			address=pre_address+":"+suf_address;
		}
		if(jQ("#ccmorecontent_btn a[affect='deadlinetime']").hasClass("on")){
			var deadlinedate=jQ("#deadlinedate_input").datepicker( "getDate" );
			var iobjtext=jQ.trim(jQ("#deadlinedate_input").next().val());
			var tmparr=iobjtext.split(":");
			deadlinedate.setHours(eval(tmparr[0]));
			deadlinedate.setMinutes(eval(tmparr[1]));
			deadlinelong=deadlinedate.getTime();
		}
	}else{
		contentArea=jQ.trim(jQ('#clip_content_area').val());
	}
	if(contentArea.length>0&&cliptype!=2){
		contentArea=contentArea.replace(/\n/g,"<br>");
		contentArea=contentArea.replace(/\r.\n/g,"<br>");
		contentArea=contentArea.replace(/<(\/?br[^>]*)>/g, "[--$1--]");
		contentArea=htmlData(contentArea);
		contentArea=contentArea.replace(/\[--([^-]+)--\]/g, "<$1>");
	}
	
	if(cliptype==3&&usertype==1){
		var tmphtml="";
		jQ("#listcontent li").each(function(i){
			if(i==0)
				tmphtml=jQ(this).find("span.name").attr("uid")
			else{
				tmphtml+=","+jQ(this).find("span.name").attr("uid")
			}
		});
		share2userlist=tmphtml;
		mlist=getMobileContacts();
	}else if(usertype==2){
		var sharetypeval=eval(jQ("#usertype2share div.choose b.clipradiobtnon").attr("typeval"));
		if(sharetypeval==1){
			var tmphtml="";
			jQ("#cclistcontent li").each(function(i){
				if(i==0)
					tmphtml=jQ(this).find("span.name").attr("uid")
					else{
						tmphtml+=","+jQ(this).find("span.name").attr("uid")
					}
			});
			share2userlist=tmphtml;
			if(!jQ("#iscanfwbox span.clipcheckbox").hasClass("clipcheckboxon"))
				iscanfw=0;
		}
//		mlist=getMobileContacts();
	}
	
	var isAsyncWeibo=0;
	if(cliptype==3||cliptype==4){
		isAsyncWeibo=jQ("#addclip_asyncweibo").data("asyncsina");
	}
	
	jQ.ajax({
		type: "POST",
		url:"eventAjax!submitClipData.action",
		data:{
			eventid:eventid,
			cliptype:cliptype,
			title:title,
			address:address,
			content:contentArea,
			eventtype:0,
			begintime:beginlong,
			endtime:endlong,
			deadlinetime:deadlinelong,
			alerttime:0,
			mobilenotice:0,
			mobilelist:'',
			status:status,
			iswholeday:iswholeday,
			share2userlist:share2userlist,
			picid:jQ("#clipevent-picid").val(),
			isAsyncWeibo:isAsyncWeibo,
			iscanfw:iscanfw
			
		},
		success:function(data){
			jQ("#loadingui").hide();
			if(data!=null){
				window.onbeforeunload = null;
				var dataObj=data;//转换为json对象
				if(dataObj.result){
					if(eval(status)==0)
						window.location.href=jQ("#ctxVal").val()+"/myclip/clip_cache.html";
					else{
						if(cliptype==2){
							window.location.href=jQ("#ctxVal").val()+"/myclip/clip_list.html#memo";
						}else{
							if(dataObj.cliptype==3||dataObj.cliptype==4){
								var visiturl=jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+dataObj.shareid;
								jQ("#add_return a.close").unbind("click").bind("click",function(){
									window.location.href=visiturl;
								});
								jQ("#add_return div.btnline button").unbind("click").bind("click",function(){
									window.location.href=visiturl;
								});
								initShareOutofSite(dataObj.shareid,title,beginlong,dataObj.clipeventpic);
								if(dataObj.eventtype!=2){
									if(dataObj.cliptype==3){
										jQ("#clipevent-eventid").val(dataObj.eventid);
										jQ("#add_return_vcode").show();
										jQ("#add_return_visit_url").val("http://"+document.domain+visiturl);
										jQ("#add_return_wrap").show();
										initClipboardOpt();
									}else{
										jQ("#clipevent-eventid").val(dataObj.eventid);
										jQ("#add_return_vcode").hide();
										jQ("#add_return_visit_url").val("http://"+document.domain+visiturl);
										jQ("#add_return_wrap").show();
										initClipboardOpt();
									}
								}else{
									jQ("#add_return_vcode").hide();
									jQ("#add_return_wrap").show();
								}
							}else
								window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+dataObj.eventid;
						}
					}
				}else{
					var errzone=jQ("#add_clip_info");
					errzone.empty();
					errzone.append(dataObj.errormsg);
					errzone.show();
				}
			}
		}
	});
}

function initClipboardOpt(){
	var clip = new ZeroClipboard( document.getElementById("add_return_copybtn"), {
		moviePath: jQ("#ctxVal").val()+"/js/common/ZeroClipboard.swf",
		positionStyle:"fixed"
	} );
	clip.addEventListener("complete",function(){
		copyOptReturnBox(jQ("#add_return_copybtn"),"复制成功");
	});
}

function copyOptReturnBox(obj,content){
	var obj_box = jQ(obj);
	var obj_offset = obj_box.offset();
	var msg_box = jQ("#accept_msg_box");
	jQ("#accept_msg_box_content").empty().append(content);
	var _top = obj_offset.top - msg_box.outerHeight()/2 ;
	var _left = obj_offset.left - msg_box.outerHeight()/2;
	msg_box.css({"top":_top+"px","left":_left+"px"}).show();
	msg_box.find("div.msg_note").animate({top: 20+'px'}, 500,function(){
		setTimeout(function(){
			msg_box.find("div.msg_note").animate({top: 100+'px'},500,function(){msg_box.hide();});
		},2000);
	});
}

function submitVCode(obj){
	if(!jQ("#add_return_vcode_ipt").hasClass("onfocus")){
		clip_tips("请输入验证码");
		return;
	}
	jQ(obj).hide();
	var vcode=jQ.trim(jQ("#add_return_vcode_ipt").val());
	var p = /^[0-9]{4}$/; 
	if(!p.test(vcode)){
		clip_tips("请输入4位数字");
		return;
	}
	jQ("#loadingui").show();
	var eventid=jQ("#clipevent-eventid").val();
	jQ.ajax({
		type: "POST",
		url:"eventAjax!submitVCode.action",
		data:{
			eventid:eventid,
			vcode:vcode
		},
		success:function(data){
			jQ("#loadingui").hide();
			if(data.result){
				jQ("#add_return_vcode_ipt").attr("disabled",true);
			}else{
				clip_tips(data.errormsg);
			}
		}
	});
	
}

function initShareOutofSite(shareid,title,beginlong,imgobj){
	var eventshareid=shareid;
	var eventtitle=title;
	var eventstarttime=beginlong;
	var day=new Date();
	day.setTime(eventstarttime);
	var startstr=day.pattern("yyyy年MM月dd日");
	jQ("#add_return div.outsitelogo a").unbind("click");
	jQ("#add_return div.outsitelogo a.renren").bind("click",function(){
		
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+eventshareid;
		var img="";
		if(imgobj!=null&&imgobj.length>0){
			img="http://"+document.domain+jQ("#ctxVal").val()+"/clippic/"+imgobj;
		}
		var rrShareParam = {
			resourceUrl : url,	//分享的资源Url
			srcUrl :url,	//分享的资源来源Url,默认为header中的Referer,如果分享失败可以调整此值为resourceUrl试试
			pic : img,		//分享的主题图片Url
			title : '档期分享：'+startstr+'  '+title,		//分享的标题
			description : '更多详情请点击'	//分享的详细描述
		};
		var temp = [];
		for( var p in rrShareParam ){
			temp.push(p + '=' + encodeURIComponent( rrShareParam[p] || '' ) )
		}
		
		
		window.open(
		'http://widget.renren.com/dialog/share?' + temp.join('&'),
		'_blank'); 
	});
	
	jQ("#add_return div.outsitelogo a.kaixin").bind("click",function(){
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+eventshareid;
		window.open(
		'http://www.kaixin001.com/repaste/share.php?rurl='+url
		+'&rtitle=档期分享'
		+'&rcontent='+startstr+'  '+eventtitle+'    '+'更多详情请点击',
		'_blank',
		'height=500,width=700,top=200,left=410,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no');
		
	});
	
	jQ("#add_return div.outsitelogo a.sina").bind("click",function(){
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+eventshareid;
		var img="";
		if(imgobj!=null&&imgobj.length>0){
			img="http://"+document.domain+jQ("#ctxVal").val()+"/clippic/"+imgobj;
		}
		var param = {
		    url:url,
		    type:'3',
		    title:'档期分享：'+startstr+'  '+eventtitle+'    '+'更多详情请点击',
		    pic:img,
		    ralateUid:'2618696840',
			language:'zh_cn',
		    rnd:new Date().valueOf()
		  }
		var temp = [];
		for( var p in param ){
			temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
		}
		window.open(
				'http://service.weibo.com/share/share.php?' + temp.join('&') ,
				'_blank',
		'height=520,width=607,top=150,left=410,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no');
	});
	jQ("#add_return div.outsitelogo a.douban").bind("click",function(){
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+eventshareid;
		window.open(
		'http://www.douban.com/recommend/?url='+url
		+'&title=档期分享'+
		+'&comment='+startstr+'  '+eventtitle+'    '+'更多详情请点击',
		'_blank',
		'height=370,width=505,top=300,left=450,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no');
	});
	jQ("#add_return div.outsitelogo a.weixin").bind("click",function(){
//		var detailurl="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+eventshareid;
//		var img="";
//		if(imgobj!=null&&imgobj.length>0){
//			img="http://"+document.domain+jQ("#ctxVal").val()+"/clippic/"+imgobj;
//		}
//		init2weixinbox("档期分享："+eventtitle,detailurl,img);
		init2weixinbox(eventshareid);
	});
	jQ("#add_return div.outsitelogo a.tqq").bind("click",function(){
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+eventshareid;
		var img="";
		if(imgobj!=null&&imgobj.length>0){
			img="http://"+document.domain+jQ("#ctxVal").val()+"/clippic/"+imgobj;
		}
		var param = {
		    url:url,
		    appkey:'',
		    title:'档期分享：'+startstr+'  '+eventtitle+'    '+'更多详情请点击',
		    pic:img,
		    site:'www.clip24.cn'
		  }
		var temp = [];
		for( var p in param ){
			temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
		}
		var _u = 'http://v.t.qq.com/share/share.php?'+ temp.join('&');
		window.open( _u,'转播到腾讯微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );

	});
}


function getContacts(){
	var list=new Array();
	jQ("#inviteuserautolist li").each(function(i){
		list.push(jQ("span.name",this).attr("uid"));
	});
	return list.toString();
}

function getMobileContacts(){
	var list=new Array();
	jQ("#inviteuserautolist li").each(function(i){
		var mobileobj=jQ("div.opt",this).find("a.mobilemsgonit");
		var flag=jQ("div.opt",this).find("a.mobilemsgonit").length>0;
		if(flag){
			var mobilenotice=mobileobj.data("mobilenotice");
			if(mobilenotice){
				list.push(jQ("span.name",this).attr("uid"));
			}
		}
	});
	return list.toString();
}

function scrollToObject(obj){
	var t = obj;
    if(t != undefined && t.offset() != null){
	    //判断是否有DOCTYPE声明，有与没有，scrollTop不一样
	    /*var scrollPos;
	    if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
	        scrollPos = document.documentElement;
	    }
	    else if (typeof document.body != 'undefined') {
	        scrollPos = document.body;
	    }*/
	   
	    var next_top = t.offset().top;
	    //jQ(scrollPos).scrollTop(next_top-100);
	    jQ(document.documentElement).animate({ scrollTop : next_top-100 }, "normal");
	    jQ(document.body).animate({ scrollTop : next_top-100 }, "normal");
    }
}

function checkClipData(status){
	
	var cliptype=eval(jQ("#addclip_maincontent").data("cliptype"));
	var usertype=eval(jQ("#var_usertype").val());
	if(usertype==2)
		cliptype=3;
	var flag=true;
	
	var beginval=jQ("#clip_begindate_input").val();
	errzone=jQ("#starttime_input_info");
	if(beginval==null||beginval.length<=0){
		errzone.empty();
		errzone.append("请选择活动日期。");
		scrollToObject(errzone);
		errzone.show();
		return false;
	}else{
		errzone.empty();
	}
	
	if(jQ("#clip_isoneday_cbx").data("checked")&&cliptype!=2){
		
		var endval=jQ("#clip_enddate_input").val();
		errzone=jQ("#starttime_input_info");
		if(endval==null||endval.length<=0){
			errzone.empty();
			errzone.append("请选择活动的结束日期。");
			scrollToObject(errzone);
			errzone.show();
			return false;
		}else{
			errzone.empty();
		}
		
	}
	
	
	var title=jQ.trim(jQ("#clip_title_input").val());
	var errzone=null;
	errzone=jQ("#title_input_info");
	var contentcheckboxlength=jQ("#clipcontent_checkboxes>p>span.clipcheckboxon").length;
	if((title==null||title.length<=0)&&contentcheckboxlength==0){
	 	errzone.empty();
		errzone.append("请选择活动内容或输入补充内容。");
		scrollToObject(errzone);
		errzone.show();
		return false;
	}else{
		if(title.length>50){
			errzone.empty();
			errzone.append("“补充内容”请控制在50字以内。");
			scrollToObject(errzone);
			errzone.show();
		}else
			errzone.empty();
	}

	var contentArea=jQ.trim(jQ('#clip_content_area').val());
	if(contentArea!="<br>"&&contentArea.length>0){
		contentArea=contentArea.replace(/\n/g,"<br>");
		contentArea=contentArea.replace(/\r.\n/g,"<br>");
		contentArea=contentArea.replace(/<(\/?br[^>]*)>/g, "[--$1--]");
		contentArea=htmlData(contentArea);
		contentArea=contentArea.replace(/\[--([^-]+)--\]/g, "<$1>");
	}
	
	errzone=jQ("#content_area_info");
	if(contentArea!=null&&contentArea.length>500){
		errzone.empty();
		errzone.append("“详情”请控制在500字以内。");
		scrollToObject(errzone);
		errzone.show();
		return false;
	}else{
		errzone.empty();
	}

	if(cliptype==3&&usertype==1){
		var templength=jQ("#listcontent li").length;
		errzone=jQ("#sharepartzone_info");
		if(templength==0){
			errzone.empty();
			errzone.append("请至少选择一名好友。");
			errzone.show();
			return false;
		}else{
			errzone.empty();
		}
	}
	if(usertype==2){
		
		jQ("#ccmorecontent_btn a.on").each(function(){
			var zone=jQ(this).attr("affect");
			if(zone=='address'){
				var pre_address=getPreAddress();
				var suf_address=jQ.trim(jQ("#address_ext_ipt").val());
				if(suf_address.length<=0){
					jQ("#ccmorecontent_errorinfo").empty().append("请输入地址");
					scrollToObject(jQ("#ccmorecontent_errorinfo"));
					flag=false;
					return flag;
				}else if(suf_address.length>100){
					jQ("#ccmorecontent_errorinfo").empty().append("地址超过100字限制");
					flag=false;
					return flag;
				}
			}else if(zone=='deadlinetime'){
				
				var deadlinedatestr=jQ("#deadlinedate_input").val();
				if(deadlinedatestr==null||deadlinedatestr.length<=0){
					jQ("#ccmorecontent_errorinfo").empty().append("请选择截止时间");
					scrollToObject(jQ("#ccmorecontent_errorinfo"));
					flag=false;
					return flag;
				}
				var begindate=jQ("#clip_begindate_input").datepicker( "getDate" );
				var iobjtext=jQ.trim(jQ("#clip_begindate_input").next().text());
				var tmparr=iobjtext.split(":");
				begindate.setHours(eval(tmparr[0]));
				begindate.setMinutes(eval(tmparr[1]));
				var deadlinedate=jQ("#deadlinedate_input").datepicker( "getDate" );
				iobjtext=jQ.trim(jQ("#deadlinedate_input").next().val());
//				tmparr=iobjtext.split(":");
//				deadlinedate.setHours(eval(tmparr[0]));
//				deadlinedate.setMinutes(eval(tmparr[1]));
				if(deadlinedate.getTime()>begindate.getTime()){
					jQ("#ccmorecontent_errorinfo").empty().append("截止时间应早于活动开始时间");
					scrollToObject(jQ("#ccmorecontent_errorinfo"));
					flag=false;
					return flag;
				}
				
			}else if(zone=='detail'){
				var contentArea=jQ.trim(jQ('#clipcc_content_area').val());
				if(contentArea!="<br>"&&contentArea.length>0){
					contentArea=contentArea.replace(/\n/g,"<br>");
					contentArea=contentArea.replace(/\r.\n/g,"<br>");
					contentArea=contentArea.replace(/<(\/?br[^>]*)>/g, "[--$1--]");
					contentArea=htmlData(contentArea);
					contentArea=contentArea.replace(/\[--([^-]+)--\]/g, "<$1>");
				}
				
				if(contentArea!=null&&contentArea.length>500){
					jQ("#ccmorecontent_errorinfo").empty().append("“详情”请控制在500字以内。");
					scrollToObject(jQ("#ccmorecontent_errorinfo"));
					flag=false
					return flag;
				}
			}
		});
		var sharetypeval=eval(jQ("#usertype2share div.choose b.clipradiobtnon").attr("typeval"));
		if(sharetypeval==1){
			var lilength=jQ("#cclistcontent li").length;
			if(lilength<=0){
				jQ("#cclistcontent").next("span").empty().append("请至少选择一位用户").show();
				flag=false
				return flag;
			}
		}
	}

	return flag;
}

//function changecliptype(obj){
//	if(eval(obj.value)==1){
//		jQ("#cliptype1moredetail").show();
//		jQ("#cliptype1shareinvite").show();
//		jQ("#clip_begindate_input").nextAll().show();
//	}else{
//		jQ("#cliptype1moredetail").hide();
//		jQ("#cliptype1shareinvite").hide();
//		jQ("#clip_begindate_input").nextAll().hide();
//		if(eval(jQ("#addclip_maincontent").data("moredetail"))){
//			jQ("#clip_inputmoredetail_cbx").click();
//		}
//		if(eval(jQ("#addclip_maincontent").data("shareinvite"))){
//			jQ("#clip_shareinvite_cbx").click();
//		}
//	}
//}

function getPreAddress(){
	var pval=eval(jQ("#provinceselect").val());
	if(pval==0){
		return "0";
	}else{
		var ptype=eval(jQ("#provinceselect option:selected").attr("type"));
		if(ptype==-1){
			var cval="0";
			var dval=eval(jQ("#districtselect").val());
			if(dval==0){
				return ""+pval;
			}else{
				return pval+"_0_"+dval;
			}
		}else{
			var cval=eval(jQ("#cityselect").val());
			if(cval==0){
				return ""+pval;
			}else{
				var dval=eval(jQ("#districtselect").val());
				if(dval==0){
					return pval+"_"+cval;
				}else{
					return pval+"_"+cval+"_"+dval;
				}
			}
		}
	}
}

function changeEventDayCBX(obj){
	if(jQ(obj).hasClass("clipcheckboxon")){
		jQ(obj).removeClass("clipcheckboxon");
		jQ(obj).data("checked",1);
		jQ("#clip_enddate_input").fadeIn();
		jQ(obj).prevAll(".endtime").fadeIn();
	}else{
		jQ(obj).addClass("clipcheckboxon");
		jQ(obj).data("checked",0);
		jQ("#clip_enddate_input").fadeOut();
		jQ(obj).prevAll(".endtime").fadeOut();
	}
}

function changeSetalerttimeCBX(obj){
	if(jQ(obj).hasClass("clipcheckboxon")){
		jQ(obj).removeClass("clipcheckboxon");
		jQ(obj).data("checked",0);
		jQ("#alerttimetr").fadeOut();
	}else{
		jQ(obj).addClass("clipcheckboxon");
		jQ(obj).data("checked",1);
		if(eval(jQ("#var_hasmobile").val()==1)){
			var html="<b class=\"mobilenotice\" onclick=\"changeMobilenoticeSta(this);\" title='短信提醒'></b>";
			jQ("#alerttimespan").append(html);
		}else{
			jQ("#alerttimespan b").remove();
		}
		jQ("#alerttimetr").fadeIn();
	}
}

function changeMobilenoticeSta(obj){
	if(jQ(obj).hasClass("onit")){
		jQ(obj).removeClass("onit");
		jQ(obj).attr("title","短信提醒");
		jQ("#clip_alertdate_input").data("mobilenotice",0);
	}else{
		jQ(obj).addClass("onit");
		jQ(obj).attr("title","取消短信提醒");
		jQ("#clip_alertdate_input").data("mobilenotice",1);
	}
}

function changeInputmoredetailCBX(obj){
	if(jQ(obj).hasClass("expandonit")){
		jQ(obj).removeClass("expandonit");
		jQ("#detail_input_table").hide();
		jQ("#addclip_maincontent").data("moredetail",0);
	}else{
		jQ(obj).addClass("expandonit");
		jQ("#detail_input_table").show();
		jQ("#addclip_maincontent").data("moredetail",1);
	}
}

function contactsChooseSwitch(obj){
	var tmpobj=jQ(obj).find("div.btn1right");
	if(tmpobj.hasClass("open")){
		tmpobj.removeClass("open").css({ 'background-position': "0 0px"});
		jQ("#mailcontactszone").fadeOut();
	}else{
		tmpobj.addClass("open").css({ 'background-position': "0 -43px"});
		jQ("#mailcontactszone").fadeIn();
	}
}

function mobilesChooseSwitch(obj){
	var tmpobj=jQ(obj).find("div.btn2right");
	if(tmpobj.hasClass("open")){
		tmpobj.removeClass("open").css({ 'background-position': "0 0px"});
		jQ("#mobilecontactszone").fadeOut();
	}else{
		tmpobj.addClass("open").css({ 'background-position': "0 -43px"});
		jQ("#mobilecontactszone").fadeIn();
	}
}

function checkMobileCheckBox(obj){
	if(jQ("#enabledmobile").css("display")!="none"){
		jQ("#mobile_show_div_cbx").attr("checked",jQ(obj).attr("checked"));
	}
}

function activeInputFlag(flag){
	if(flag){
		
	}else{
		
	}
}

function errorUploadCallback(){
	clip_tips("上传的图片不能超过5M");
	jQ("div.afteruploadinf").empty().hide();
	jQ("div.inguploadinf a").unbind("click").hide();
	jQ("div.inguploadinf").hide();
	jQ("#addclipbutton").removeClass("disableaddclip").bind("click",addclip);
	jQ("div.preuploadinf").show();
}

function uploadCallback(returnpicid,weburl){
	jQ("#clipevent-picid").val(returnpicid);
	jQ("div.inguploadinf").hide();
	var html="";
	html+="<img src='"+jQ("#ctxVal").val()+weburl+"' onload='resizeImg(this)' style='display:none;'>";
	html+="<a title='删除图片'></a>";
	jQ("div.afteruploadinf").empty().append(html).show();
	jQ("div.afteruploadinf a").unbind("click").bind("click",deleteUploadClippic);
	jQ("#addclipbutton").removeClass("disableaddclip").unbind("click").bind("click",addclip);
}

function deleteUploadClippic(){
	var picid=jQ("#clipevent-picid").val(); 
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteUploadClippic.action",
		data:{
			picid:eval(picid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ("div.preuploadinf").show();
					jQ("div.afteruploadinf").empty().hide();
				}
			}
		}
	});
}

function syncWeibo(){
	jQ.ajax({
		type: "POST",
		url:"eventAjax!syncWeibo.action",
		success:function(data){
			if(data.result){
				alert("成功statusid="+data.statusid);
			}else{
				alert("失败");
			}
		}
	});
}


function resizeImg(img){
	var LastestWIDTH=90;
	var LastestHEIGHT=50;
    if(typeof(img)!='object')
        img=document.getElementById(img);
    if(img==null)
        return;
    var image=document.createElement("img");
    image.onload=function (){
        var width=this.width;
        var height=this.height;
        if(width>LastestWIDTH||height>LastestHEIGHT){
        	var a=LastestHEIGHT/LastestWIDTH;
        	var b=height/width;
	        if(b > a){
	        	img.height=LastestHEIGHT;
	        }else{
	        	img.width=LastestWIDTH;
	        }
        }
        jQ(img).prev().hide();
        jQ(img).fadeIn();
    };
    image.src=img.src;
}